package com.atguigu.juc.day04.cf;

import com.atguigu.juc.day04.pool.Demo01MyPool;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;

public class Demo08SupplyThenAccept {

    public static void main(String[] args) {

        ExecutorService executorService = Demo01MyPool.getExecutorService();

        // thenAccept()方法：通过 Consumer 类型的对象接收前面任务返回的结果
        CompletableFuture
                .supplyAsync(() -> "first task result", executorService)
                .thenAccept(prevTaskResult -> System.out.println("prevTaskResult = " + prevTaskResult));

    }

}
